package com.okilo.online.app.apt

import android.widget.LinearLayout
import androidx.recyclerview.widget.RecyclerView
import com.okilo.online.app.R
import com.okilo.online.app.tools.apt.OkiloRecyclerViewAdapter
import com.okilo.online.app.tools.apt.OkiloViewHolderHelper
import org.json.JSONObject

/**
 * OkiloLoan
 * @Author wwdeng
 * @CreateTime: 2024/11/19 13:54
 * @Annotation：认证流程 - 性别选择
 */
class OkiloStepGenderItemApt(recyclerView: RecyclerView?) :
    OkiloRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.okilo_fmt_step_general_gender_child_item) {
    override fun setItemChildListener(helper: OkiloViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.okiloProcessStepGenderItemLayout)//选择
    }

    override fun fillData(helper: OkiloViewHolderHelper, position: Int, model: JSONObject) {
        val okiloProcessStepGenderItemLayout = helper.getView<LinearLayout>(R.id.okiloProcessStepGenderItemLayout)
        val okiloProcessStepGenderTitle = helper.getTextView(R.id.okiloProcessStepGenderTitle)
        val okiloProcessStepGenderStatus = helper.getImageView(R.id.okiloProcessStepGenderStatus)
        okiloProcessStepGenderTitle.text = model.optString("title")

        if (model.optBoolean("isSelected", false)) {
            okiloProcessStepGenderItemLayout.setBackgroundResource(R.drawable.okilo_process_step_gender_selected_bg)
            okiloProcessStepGenderStatus.setImageResource(R.mipmap.okilo_process_step_gender_selected)
            okiloProcessStepGenderTitle.setTextColor(getColor(R.color.okilo_color_white))
        } else {
            okiloProcessStepGenderItemLayout.setBackgroundResource(R.drawable.okilo_process_step_input_normal_bg)
            okiloProcessStepGenderStatus.setImageResource(R.mipmap.okilo_process_step_gender_normal)
            okiloProcessStepGenderTitle.setTextColor(getColor(R.color.okilo_color_ff747378))
        }
    }
}